// pages/mine/coupon/coupon.js
const app = getApp();
const util = require("../../../utils/util.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    couponList: [],
    isNoProduct: true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    // 请求优惠券列表
    let myCouponListUrl = app.globalData.baseUrl + "weixin/myCouponList"
    let cid = wx.getStorageSync('cid')
    let data = {
      cid: cid
    }
    util.requestLoading(myCouponListUrl, data, "GET").then(res => {
      // console.log(res)
      that.setData({
        couponList: res.data.couponList
      })
      if (that.data.couponList.length == 0) {
        isNoProduct: false
      }
    })
  },
})